package com.neusoft.neuiotms.dcom.converter.change;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSON;
import com.neusoft.bizcore.activiti.converter.AbstractServiceDataConverter;
import com.neusoft.bizcore.activiti.dto.DataModelDTO;
import com.neusoft.bizcore.activiti.dto.ServiceDataModelDTO;
import com.neusoft.bizcore.activiti.enums.OperationTypeEnum;
import com.neusoft.neuiotms.dcom.dto.change.ChangeCiRelationDataDTO;

@Component
public class ChangeCiRelationDataConverter extends AbstractServiceDataConverter<ChangeCiRelationDataDTO> {

    @Override
    public List<ServiceDataModelDTO> converter(final List<ChangeCiRelationDataDTO> list, final String serviceName,
            final OperationTypeEnum type) {
        final List<ServiceDataModelDTO> newList = new ArrayList<>();

        list.stream().forEach(e -> {
            final ServiceDataModelDTO sdm = new ServiceDataModelDTO();
            final DataModelDTO dm = new DataModelDTO();
            sdm.setServiceName(serviceName);

            // 此处可对需要转化的业务数据进行处理
            dm.setJsonData(JSON.toJSONString(e));
            dm.setType(type);

            sdm.setData(dm);
            newList.add(sdm);
        });

        return newList;
    }

}
